﻿using System;
using System.Collections.Generic;
using System.Collections.ObjectModel;
using System.Threading.Tasks;
using com.IronOne.BoardPACWinAppBO.Comment;
using com.IronOne.BoardPACWinAppDAO.Comments;

namespace com.IronOne.BoardPACWinAppService.Comment
{
    public class CommentService : ICommentService
    {
        private readonly ICommentsDAO _commentsDAO;

        public CommentService()
        {
            _commentsDAO = new CommentsDAO();
        }

        public async Task<ObservableCollection<CommentModel>> GetAllComments()
        {
            //TODO : Get Comments from the database and populate list
            try
            {
                return await _commentsDAO.GetAllComments();
            }
            catch (Exception)
            {
                throw;
            }
        }

        /// <summary>
        ///     Return comments model list according to comment type
        /// </summary>
        /// <param name="refId"></param>
        /// <param name="commentType"></param>
        /// <returns></returns>
        public async Task<ObservableCollection<CommentModel>> GetCommentTypeWiseComment(int refId, int commentType)
        {
            try
            {
                return await _commentsDAO.GetCommentTypeWiseComment(refId, commentType);
            }
            catch (Exception)
            {
                throw;
            }
        }

        /// <summary>
        /// </summary>
        /// <param name="commentType">Paper or Meeting Comment</param>
        /// <param name="action"></param>
        /// <param name="comment"></param>
        /// <param name="refId"></param>
        /// <param name="meetingId"></param>
        /// <returns></returns>
        public async Task<bool> AddComments(int commentType, string action, string comment, int refId, int meetingId)
        {
            try
            {
                return await _commentsDAO.AddComments(commentType, action, comment, refId, meetingId);
            }
            catch (Exception)
            {
                throw;
            }
        }

        public async Task<bool> UpdateViewedComments(string action, List<int> meetingIds, List<int> paperIds)
        {
            try
            {
                return await _commentsDAO.UpdateViewedComments(action, meetingIds, paperIds);
            }
            catch (Exception)
            {
                throw;
            }
        }

        public async Task<int> GetPendingMeetingAndPaperComments()
        {
            try
            {
                return await _commentsDAO.GetPendingMeetingAndPaperComments();
            }
            catch (Exception)
            {
                throw;
            }
        }
    }
}